
                <div class="tableMain">
                    
                    
                    <form method="post" enctype="multipart/form-data" action="index.php?admin=1&c=goods&a=add" >
                    <label>商品名称:</label><input name="name" type="text" /><br/>
                    <label>分类:</label>
                    <p class="select">
                        <select name="category_id">  
                          <option value="" disabled="disabled" selected="selected">请选择</option>
                          <?php foreach ($arr as $key => $value):?>
                          <option value="<?php echo $value['id'];?>"><?php echo $value['name'];?></option>
                          <?php endforeach;?>
                        </select>
                    </p>
                    <p>
                     <label>品牌:</label>
                    <select name="brand_id">
                          <?php foreach ($brand as $key => $value):?>
                          <option value="<?php echo $value['id'];?>"><?php echo $value['name'];?></option>
                          <?php endforeach;?>
                     </select>
                     </p>
                    <label>价钱:</label><input name="price" type="text" /><br/>
                    <label>库存:</label><input name="nums" type="text" /><br/>
                    <label>图片:</label><span><input type="button" class="addfile" value="+" />&nbsp;&nbsp;<input type="button" class="delfile" value="-" />5m以内</span>
                    <p>
                      <input type="file" name="image[]" />
                    </p>
                    <label>商品详情:</label><textarea id="textarea" name="info" cols="80" rows="12"></textarea><br/>
                    
                    <input type="submit" value="添加"/>
                    </form>   
                   
                </div>
                <div id="page">
                <ul>
				
                </ul>
           		</div>
		  <script>
        
        $('.addfile').click(function(){
          var file='<input type="file" name="image[]" />';
          var len=$(this).parent().next('p').find('input').length;
          if(len<5){
            $(this).parent().next('p').append(file);
          }else{ alert('够多了');}
        })
        $('.delfile').click(function(){
          var len=$(this).parent().next('p').find('input').length;
          if(len>1){
          $(this).parent().next('p').find('input').eq(len-1).remove();
        }else{ alert('要没了');}
        })
        
                $('select').live('change',function(){
                    var id=$(this).val();
                    $(this).nextAll().remove();
                    var index=$(this).get(0).selectedIndex;
                    if(!index){
                        return false;
                    }
                    var url="index.php?admin=1&c=category&a=add";
                    $.ajax({
                        type:"post",
                        url:url,
                        data:{id:id},
                        dataType:"json",
                        success:function(json){
                            //alert(json[0].name);
                            if(json[0]){
                                var str='';
                                str+='<select style="margin-left:10px;" name="pid">';
                                str+='<option value="'+id+'">上一级</option>';
                                var i;
                                for (i in json) {
                                    str+='<option value="'+json[i].id+'">'+json[i].name+'</option>';
                                };
                                str+='</select>';

                                $('.select').append(str);
                            }
                        }
                    })
                    
                })
       
      </script>